﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
using System.Data.SqlClient;
using System.Web.Configuration;

namespace TRAVEL11
{
    /// <summary>
    /// Summary description for WebService1
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class WebService1 : System.Web.Services.WebService
    {

        //static string strcon = WebConfigurationManager.ConnectionStrings["connection"].ConnectionString;
        static string strconn = WebConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString;

        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }

        [WebMethod]
        public int Sum(int a, int b)
        {
            return a + b;
        }

        [WebMethod]
        public DataSet ShowCus()
        {
            SqlConnection con = new SqlConnection(strconn);
            string sql = "select * from SYS_tblCustomerTourList";
            SqlDataAdapter da = new SqlDataAdapter(sql, con);
            DataSet ds = new DataSet();
            da.Fill(ds);
            con.Close();
            return ds;
        }

        [WebMethod]
        public DataSet ShowLocation()
        {
            string query = "select LocationId,Country,LocationName from dbo.SYS_tblLocation where STATUS like N'Kích hoạt'";
            SqlConnection conn = new SqlConnection(strconn);
            conn.Open();

            SqlDataAdapter da = new SqlDataAdapter(query, conn);
            DataSet ds = new DataSet();

            da.Fill(ds);
            conn.Close();
            return ds;
        }
    }
}
